package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import ezy.lite.util.ContextUtil;
import ezy.widget.view.AutofitImageView;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Integral;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.PanicBuyDetailActivity;

/**
 * Created by Administrator on 2016/4/26 0026.
 */
public class IntegralAdapter extends ItemAdapter<Integral, IntegralAdapter.IntegralViewHolder> {
    private Context context;

    public IntegralAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public IntegralAdapter.IntegralViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new IntegralViewHolder(inflate(R.layout.item_integral_shop, parent));
    }

    @Override
    public void onBindViewHolder(IntegralAdapter.IntegralViewHolder holder, int position) {
        Integral item = getItem(position);
        Glide.with(context).load(item.image).into(holder.imgShop);
        holder.txtTitle.setText(item.title);
        holder.txtIntegral.setText("积分：" + item.jifen);
        holder.txtYuanjia.setText("原价:" + item.yuanjia);
        holder.txtYuanjia.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); //中划线
        holder.txtNum.setText("数量：" + item.num);
        holder.txtYidui.setText("已兑：" + item.yidui);

    }

    static class IntegralViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.img_shop)
        AutofitImageView imgShop;

        @BindView(R.id.txt_title)
        TextView txtTitle;
        @BindView(R.id.txt_integral)
        TextView txtIntegral;
        @BindView(R.id.txt_yuanjia)
        TextView txtYuanjia;
        @BindView(R.id.txt_num)
        TextView txtNum;
        @BindView(R.id.txt_yidui)
        TextView txtYidui;
        @BindView(R.id.btn_duihuan)
        Button btnDuihuan;


        public IntegralViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ContextUtil.startActivity(v.getContext(), PanicBuyDetailActivity.class);
                }
            });
        }

    }
}
